#include "searchlineedit.h"

SearchLineEdit::SearchLineEdit(QWidget* parent)
    :QLineEdit{parent}
{
    QLabel* label = new QLabel(this);
    label->setFixedSize(16,16);
    label->setPixmap(QPixmap(":/images/homePage/sousuo.png"));

    QPushButton* btn = new QPushButton(this);
    btn->setText("搜索");
    btn->setFixedSize(62,32);
    btn->setCursor(Qt::ArrowCursor);
    btn->setStyleSheet("background-color : #3ECEFE;"
                        "border-radius : 16px;"
                        "font-family : 微软雅⿊;"
                        "font-size : 14px;"
                        "color : #FFFFFF;"
                        "font-style : normal;");

    this->setPlaceholderText("请输入你感兴趣的内容");
    this->setFixedWidth(320);
    this->setFixedHeight(36);
    this->setStyleSheet("QLineEdit{ "
                        "background-color: #FFFFFF; "
                        "border-radius: 18px; "
                        "border: 1px solid #3ECEFE; "
                        "font-family: '微软雅黑', 'Microsoft YaHei', sans-serif; "
                        "font-size: 14px; "
                        "font-style: normal; "
                        "}");
    this->setTextMargins(33,0,0,0);

    QHBoxLayout* layout = new QHBoxLayout(this);
    layout->addWidget(label);
    layout->addStretch();
    layout->addWidget(btn);
    layout->setContentsMargins(11,0,2,0);

    connect(btn,&QPushButton::clicked,this,&SearchLineEdit::searchClicked);
    connect(this,&QLineEdit::returnPressed,this,&SearchLineEdit::searchClicked);
}

void SearchLineEdit::searchClicked()
{
    LOG()<<"搜索事件触发";
}


